package wkt;

import cn.hutool.core.text.CharSequenceUtil;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

public class WebUtils {
    public static Long studentId() {
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        final String header = request.getHeader("Student-Id");
        if (CharSequenceUtil.isNotBlank(header)) {
            return Long.parseLong(header);
        }
        return null;
    }
}
